package inherit;

import com.sun.media.jfxmediaimpl.HostUtils;

public class Dad {
    private String name;
    private int age;

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

//    public void sayHi () {
//        System.out.println(name + "says Hi!");
//    }

    protected void sayHi () {
        System.out.println(name + "says Hi!");
    }
}
class Son extends Dad {
    public Son(String name, int age) {
        setName(name);
        setAge(age);
    }

//    @Override
//    public void sayHi () {
//        System.out.println(getName() + "says Hello!");
//    }

    @Override
    protected void sayHi () {
        System.out.println(getName() + " says Hello!");
    }
}
class Dau extends Dad {
    public Dau(String name, int age) {
        setName(name);
        setAge(age);
    }

    @Override
    protected void sayHi () {
        System.out.println(getName() + " says Sup!");
    }
}
class Test {

    public static void main(String[] args) {
        test(new Son("Matty", 20));
        test(new Dau("Lyh",19));
    }

    public static void test (Dad dad) {
        dad.sayHi();
    }

//    public static void main(String[] args) {
//        Dad d1 = new Son("Matty",20);
//        Dad d2 = new Dau("Lyh",19);
//        d1.sayHi();
//        d2.sayHi();
//    }
}
